//命名导出(能导出多个)

export const render = (element, container)=>{
    const {type,props} = element;
    const child = document.createElement(type);
    Object.keys(props).forEach(attr =>{
      if(attr == "children"){
        // render(attr,child);
        const children = props['children']
        if(typeof children == 'string'){
          child.innerText = children;
        }else if(children instanceof Array){
          children.forEach(item =>{
            if(typeof item == "string"){
              const text = document.createTextNode(item);
              child.appendChild(text);
            }else{
              render(item,child);
            }
          })
        }else{
          render(children, child);
        }
      }else{
        child[attr] = props[attr];
      }
    })
    container.appendChild(child);
  }
  //默认导出(只能导出一个)
export default render;